package algorithm;

import java.util.Arrays;
import java.util.List;

/**
 * 119. 杨辉三角 II
 * @author Panbo Guo
 * @date 2021/8/3
 */
public class T00119 {

    public static void main(String[] args) {
        System.out.println(new Solution().getRow(10));
    }

    static class Solution {
        public List<Integer> getRow(int rowIndex) {
            rowIndex += 1;
            Integer[] arr = new Integer[rowIndex];
            Arrays.fill(arr, 1);
            for (int r = 2; r < rowIndex; r++) {
                int p = arr[0];
                for (int j = 1; j < r; j++) {
                    int t = arr[j];
                    arr[j] = arr[j] + p;
                    p = t;
                }
            }
            return Arrays.asList(arr);
        }
    }
}
